home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / java / io / PrintWriter.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  3.5 KB  |  342 lines

  1. package java.io;
  2.  
  3. public class PrintWriter extends Writer {
  4.    private Writer out;
  5.    private boolean autoFlush;
  6.    private boolean trouble;
  7.    private String lineSeparator;
  8.  
  9.    public PrintWriter(Writer var1) {
  10.       this(var1, false);
  11.    }
  12.  
  13.    public PrintWriter(Writer var1, boolean var2) {
  14.       super(var1);
  15.       this.autoFlush = false;
  16.       this.trouble = false;
  17.       this.out = var1;
  18.       this.autoFlush = var2;
  19.       SecurityManager.enablePrivilege("UniversalPropertyWrite");
  20.       this.lineSeparator = System.getProperties().getProperty("line.separator");
  21.    }
  22.  
  23.    public PrintWriter(OutputStream var1) {
  24.       this(var1, false);
  25.    }
  26.  
  27.    public PrintWriter(OutputStream var1, boolean var2) {
  28.       this((Writer)(new BufferedWriter(new OutputStreamWriter(var1))), var2);
  29.    }
  30.  
  31.    private void ensureOpen() throws IOException {
  32.       if (this.out == null) {
  33.          throw new IOException("Stream closed");
  34.       }
  35.    }
  36.  
  37.    public void flush() {
  38.       try {
  39.          Object var1 = super.lock;
  40.          synchronized(var1){}
  41.  
  42.          try {
  43.             this.ensureOpen();
  44.             this.out.flush();
  45.          } catch (Throwable var4) {
  46.             throw var4;
  47.          }
  48.  
  49.       } catch (IOException var5) {
  50.          this.trouble = true;
  51.       }
  52.    }
  53.  
  54.    public void close() {
  55.       try {
  56.          Object var1 = super.lock;
  57.          synchronized(var1){}
  58.  
  59.          try {
  60.             if (this.out != null) {
  61.                this.out.close();
  62.                this.out = null;
  63.                return;
  64.             }
  65.          } catch (Throwable var5) {
  66.             throw var5;
  67.          }
  68.  
  69.       } catch (IOException var6) {
  70.          this.trouble = true;
  71.       }
  72.    }
  73.  
  74.    public boolean checkError() {
  75.       if (this.out != null) {
  76.          this.flush();
  77.       }
  78.  
  79.       return this.trouble;
  80.    }
  81.  
  82.    protected void setError() {
  83.       this.trouble = true;
  84.    }
  85.  
  86.    public void write(int var1) {
  87.       try {
  88.          Object var2 = super.lock;
  89.          synchronized(var2){}
  90.  
  91.          try {
  92.             this.ensureOpen();
  93.             this.out.write(var1);
  94.          } catch (Throwable var6) {
  95.             throw var6;
  96.          }
  97.  
  98.       } catch (InterruptedIOException var7) {
  99.          Thread.currentThread().interrupt();
  100.       } catch (IOException var8) {
  101.          this.trouble = true;
  102.       }
  103.    }
  104.  
  105.    public void write(char[] var1, int var2, int var3) {
  106.       try {
  107.          Object var4 = super.lock;
  108.          synchronized(var4){}
  109.  
  110.          try {
  111.             this.ensureOpen();
  112.             this.out.write(var1, var2, var3);
  113.          } catch (Throwable var8) {
  114.             throw var8;
  115.          }
  116.  
  117.       } catch (InterruptedIOException var9) {
  118.          Thread.currentThread().interrupt();
  119.       } catch (IOException var10) {
  120.          this.trouble = true;
  121.       }
  122.    }
  123.  
  124.    public void write(char[] var1) {
  125.       this.write((char[])var1, 0, var1.length);
  126.    }
  127.  
  128.    public void write(String var1, int var2, int var3) {
  129.       try {
  130.          Object var4 = super.lock;
  131.          synchronized(var4){}
  132.  
  133.          try {
  134.             this.ensureOpen();
  135.             this.out.write(var1, var2, var3);
  136.          } catch (Throwable var8) {
  137.             throw var8;
  138.          }
  139.  
  140.       } catch (InterruptedIOException var9) {
  141.          Thread.currentThread().interrupt();
  142.       } catch (IOException var10) {
  143.          this.trouble = true;
  144.       }
  145.    }
  146.  
  147.    public void write(String var1) {
  148.       this.write((String)var1, 0, var1.length());
  149.    }
  150.  
  151.    private void newLine() {
  152.       try {
  153.          Object var1 = super.lock;
  154.          synchronized(var1){}
  155.  
  156.          try {
  157.             this.ensureOpen();
  158.             this.out.write(this.lineSeparator);
  159.             if (this.autoFlush) {
  160.                this.out.flush();
  161.             }
  162.          } catch (Throwable var5) {
  163.             throw var5;
  164.          }
  165.  
  166.       } catch (InterruptedIOException var6) {
  167.          Thread.currentThread().interrupt();
  168.       } catch (IOException var7) {
  169.          this.trouble = true;
  170.       }
  171.    }
  172.  
  173.    public void print(boolean var1) {
  174.       this.write(var1 ? "true" : "false");
  175.    }
  176.  
  177.    public void print(char var1) {
  178.       this.write(String.valueOf(var1));
  179.    }
  180.  
  181.    public void print(int var1) {
  182.       this.write(String.valueOf(var1));
  183.    }
  184.  
  185.    public void print(long var1) {
  186.       this.write(String.valueOf(var1));
  187.    }
  188.  
  189.    public void print(float var1) {
  190.       this.write(String.valueOf(var1));
  191.    }
  192.  
  193.    public void print(double var1) {
  194.       this.write(String.valueOf(var1));
  195.    }
  196.  
  197.    public void print(char[] var1) {
  198.       this.write(var1);
  199.    }
  200.  
  201.    public void print(String var1) {
  202.       if (var1 == null) {
  203.          var1 = "null";
  204.       }
  205.  
  206.       this.write(var1);
  207.    }
  208.  
  209.    public void print(Object var1) {
  210.       this.write(String.valueOf(var1));
  211.    }
  212.  
  213.    public void println() {
  214.       Object var1 = super.lock;
  215.       synchronized(var1){}
  216.  
  217.       try {
  218.          this.newLine();
  219.       } catch (Throwable var3) {
  220.          throw var3;
  221.       }
  222.  
  223.    }
  224.  
  225.    public void println(boolean var1) {
  226.       Object var2 = super.lock;
  227.       synchronized(var2){}
  228.  
  229.       try {
  230.          this.print(var1);
  231.          this.newLine();
  232.       } catch (Throwable var4) {
  233.          throw var4;
  234.       }
  235.  
  236.    }
  237.  
  238.    public void println(char var1) {
  239.       Object var2 = super.lock;
  240.       synchronized(var2){}
  241.  
  242.       try {
  243.          this.print(var1);
  244.          this.newLine();
  245.       } catch (Throwable var4) {
  246.          throw var4;
  247.       }
  248.  
  249.    }
  250.  
  251.    public void println(int var1) {
  252.       Object var2 = super.lock;
  253.       synchronized(var2){}
  254.  
  255.       try {
  256.          this.print(var1);
  257.          this.newLine();
  258.       } catch (Throwable var4) {
  259.          throw var4;
  260.       }
  261.  
  262.    }
  263.  
  264.    public void println(long var1) {
  265.       Object var3 = super.lock;
  266.       synchronized(var3){}
  267.  
  268.       try {
  269.          this.print(var1);
  270.          this.newLine();
  271.       } catch (Throwable var5) {
  272.          throw var5;
  273.       }
  274.  
  275.    }
  276.  
  277.    public void println(float var1) {
  278.       Object var2 = super.lock;
  279.       synchronized(var2){}
  280.  
  281.       try {
  282.          this.print(var1);
  283.          this.newLine();
  284.       } catch (Throwable var4) {
  285.          throw var4;
  286.       }
  287.  
  288.    }
  289.  
  290.    public void println(double var1) {
  291.       Object var3 = super.lock;
  292.       synchronized(var3){}
  293.  
  294.       try {
  295.          this.print(var1);
  296.          this.newLine();
  297.       } catch (Throwable var5) {
  298.          throw var5;
  299.       }
  300.  
  301.    }
  302.  
  303.    public void println(char[] var1) {
  304.       Object var2 = super.lock;
  305.       synchronized(var2){}
  306.  
  307.       try {
  308.          this.print(var1);
  309.          this.newLine();
  310.       } catch (Throwable var4) {
  311.          throw var4;
  312.       }
  313.  
  314.    }
  315.  
  316.    public void println(String var1) {
  317.       Object var2 = super.lock;
  318.       synchronized(var2){}
  319.  
  320.       try {
  321.          this.print(var1);
  322.          this.newLine();
  323.       } catch (Throwable var4) {
  324.          throw var4;
  325.       }
  326.  
  327.    }
  328.  
  329.    public void println(Object var1) {
  330.       Object var2 = super.lock;
  331.       synchronized(var2){}
  332.  
  333.       try {
  334.          this.print(var1);
  335.          this.newLine();
  336.       } catch (Throwable var4) {
  337.          throw var4;
  338.       }
  339.  
  340.    }
  341. }
  342.